<template>
	<view class="page-content" v-if="examInfo">
		<!-- <view class="banner">
			产品图占位或其他内容
		</view> -->
		<!-- examScoreSet: // 1:大分项 2:小分项 -->
		<luBarTabNav :tabList="tabList" :barFixed="barFixed" :iconShow="iconShow" :transitionShow="transitionShow"
			:barHeight="barHeight" :barTop="barTop" :barId="barId" ref="barTabNav">
			<view id="item1" class="tabbody">
				<view class="title">题目</view>
				<view class="innerBox" v-if="examInfo.examInfoProps">
					{{ examInfo.examInfoProps.examName }}
				</view>
			</view>
			<view id="item2" class="tabbody">
				<view class="title">题干</view>
				<view class="innerBox" v-if="examInfo.examInfoProps">
					{{ examInfo.examInfoProps.examText }}
				</view>
			</view>
			<view id="item3" class="tabbody">
				<view class="title">重要知识点</view>
				<view class="innerBox">
					<view v-for='(item,index) in examInfo.cueCardList' :key='index'>
						{{ item.cueContent }}
					</view>
				</view>
			</view>
			<view id="item5" class="tabbody">
				<view class="title">考评打分</view>
				 <!-- 1：大分项       2：小分项 -->
				 <!-- 大分项 -->
				<view v-if="examScoreSet == '1'" class="innerBox innerBox1">
					<view class="wuzi-box">
						<view class="left left1">大类</view>
						<view class="mid mid1">判断标准</view>
						<view class="right right1">小分项</view>
						<view class="right right1">满分</view>
						<view class="right right2">实际得分</view>
					</view>
					<view v-for="(item,index) in scoreCardList" :key="index" class="innerTitle" style="display: flex;overflow: hidden;" @click="chooseExamBig(item, index)">
						<view class="left left1" style="width: 140rpx;display: flex;justify-content: center;align-items: center;border: 1px solid #00796B50;border-top: none;">{{ item.item }}</view>
						<view style="flex: 1;">
							<view v-for="(q,i) in item.children" :key="i" style="display: flex;">
								<view style="flex: 1;line-height: 30rpx;padding: 10rpx ;border-bottom: 1px solid #00796B50;border-right: 1px solid #00796B50;">
									{{ q.scoreCardScoringCriteria }}
								</view>
								<view style="width: 80rpx;display: flex;align-items:center;justify-content: center;border-bottom: 1px solid #00796B50;border-right: 1px solid #00796B50;color: #999;">
									{{ q.scoreCardTotalScore }}
								</view>
								
							</view>
						</view>
						<view class="right right2" style="width: 80rpx;display: flex;justify-content: center;align-items: center;border-bottom: 1px solid #00796B50;border-right: 1px solid #00796B50;">{{ item.itemScore }}</view>
						<view style="width: 100rpx;display: flex;align-items:center;justify-content: center;border-bottom: 1px solid #00796B50;border-right: 1px solid #00796B50;font-size: 20rpx;color: #00796B;font-weight: 600;">
							<view v-if="item.itemScoreResult >= item.itemScore * 0.8" style="color: rgb(0, 121, 107)" >{{ item.itemScoreResult }}</view>
							<view v-if="item.itemScoreResult >= item.itemScore * 0.6 && item.itemScoreResult < item.itemScore * 0.8" style="color: orange">{{ item.itemScoreResult }}</view>
							<view v-if="item.itemScoreResult < item.itemScore * 0.6" style="color: #FF001F">{{ item.itemScoreResult }}</view>
						</view>
					</view>
				</view>
				<!-- 小分项 -->
				<view v-if="examScoreSet == '2'" class="innerBox innerBox1">
					<view class="wuzi-box">
						<view class="left left1">大类</view>
						<view class="mid mid1">判断标准</view>
						<view class="right right1">满分</view>
						<view class="right right2">实际得分</view>
					</view>
					<view v-for="(item,index) in scoreCardList" :key="index" class="innerTitle" style="display: flex;overflow: hidden;">
						<view class="left left1" style="width: 140rpx;display: flex;justify-content: center;align-items: center;border: 1px solid #00796B50;border-top: none;">{{ item.item }}</view>
						<view style="flex: 1;">
							<view v-for="(q,i) in item.children" :key="i" style="display: flex;" @click="chooseExam(q)">
								<view style="flex: 1;line-height: 30rpx;padding: 10rpx ;border-bottom: 1px solid #00796B50;border-right: 1px solid #00796B50;">
									{{ q.scoreCardScoringCriteria }}
								</view>
								<view style="width: 80rpx;display: flex;align-items:center;justify-content: center;border-bottom: 1px solid #00796B50;border-right: 1px solid #00796B50;">
									{{ q.scoreCardTotalScore }}
								</view>
								<view style="width: 100rpx;display: flex;align-items:center;justify-content: center;border-bottom: 1px solid #00796B50;border-right: 1px solid #00796B50;font-size: 20rpx;color: #00796B;font-weight: 600;">
									<view v-if="q.result >= q.scoreCardTotalScore * 0.8" style="color: rgb(0, 121, 107)" >{{ q.result }}</view>
									<view v-if="q.result >= q.scoreCardTotalScore * 0.6 && q.result < q.scoreCardTotalScore * 0.8" style="color: orange">{{ q.result }}</view>
									<view v-if="q.result < q.scoreCardTotalScore * 0.6" style="color: #FF001F">{{ q.result }}</view>
								</view>
							</view>
						</view>
					</view>
				  <!-- {{scoreCardList}} -->
				</view>
				
			</view>
		</luBarTabNav>
		<view class="fixed-score-box flex-center">
			<view class="top-box">
				<view class="score-box-outer">
					<view class="score-des" style="display: flex;">
						<view style="width: 60rpx;text-align: right;">得分：</view>
						<view style="width: 200rpx;text-align: left;">
							<view v-if="allScore >= matchScore * 0.8" style="display: flex;justify-content: flex-start;align-items: center;color: rgb(0, 121, 107)" >
								{{ allScore }}分
								<view style="font-size: 10rpx;padding-left: 6rpx;">（良好）</view>
							</view>
							<view v-if="allScore >= matchScore * 0.6 && allScore < matchScore * 0.8" style="display: flex;align-items: center;justify-content: flex-start;color: orange">
								{{ allScore }}分
								<view style="font-size: 10rpx;padding-left: 6rpx;">（及格）</view>
							</view>
							<view v-if="allScore < matchScore * 0.6" style="display: flex;justify-content: flex-start;align-items: center;color: #FF001F">
								{{ allScore }}分
								<view style="font-size: 10rpx;padding-left: 6rpx;">（不及格）</view>
							</view>
						</view>
					</view>
					<view class="score-num" >
						<view style="display: flex;">
							<view style="width: 60rpx;text-align: right;">满分：</view> 
							<view style="width: 200rpx;text-align: left;">{{ matchScore }}分</view>
						</view>
					</view>
				</view>
				<view class="btn-box flex-center" style="flex: 1;">
					<view class="info-wrap flex-center" style="width: 100%">
						<view v-if="ifPermission === '2'" style="width: 100px">驳回原因：</view>
						<view v-if="ifPermission === '2'" style="width: 100%" @click="toShow">
								<u-notice-bar :text="permissionText" style="width: 100%" bgColor='#aa0015' color='#fff' fontSize='16' speed='0'></u-notice-bar>
						</view>
					</view>
				</view>
			</view>
			<view class="bottom-box" style="display: flex;">
				
				<u-button v-if="ifPermission === null" type="primary" shape="circle" text="申请修改成绩" color="#00796B" style="font-weight: 600; height: 45px" @click="updateExam"></u-button>
				<u-button v-if="ifPermission === '2'" type="primary" shape="circle" text="申请驳回，继续申请" color="#aa0015" style="font-weight: 600; height: 45px" @click="updateExam"></u-button>
				<u-button v-if="ifPermission === '0'" type="primary" shape="circle" text="申请修改审核中" color="orange" style="font-weight: 600; height: 45px"  :disabled='true'></u-button>
				<u-button v-if="ifPermission === '1'" type="primary" shape="circle" text="提交" color="#00796B" style="font-weight: 600; height: 45px" @click="submit"></u-button>
			</view>
		</view>
		<!-- 打分 大分项start -->
		<u-modal :show="showScore" @confirm="scoreHandle"  confirmColor='#00796B' :showCancelButton='false' width='460px'>
			<view style="width: 100%;display: flex;flex-direction: column;align-items: center;justify-content: center;">
				<view style="font-size: 20rpx;font-weight: 600;padding-bottom: 10rpx;">题干：</view>
				<view style="text-align: left;max-height: 100rpx;overflow: auto;width: 100%">{{ chooseExamObj.scoreCardScoringCriteria }}</view>
				<view class="score-handle-box">
					<view class="score-handle-inner">
						<view class="minScore">0</view>
						<u-slider v-model="chooseExamObj.result" :step="Number(examScoreMin)" min="0"
							:max="chooseExamObj.scoreCardTotalScore" block-width="40" block-color="#00796B"
							activeColor="#00796B" inactiveColor=" #D9D9D9;" :showValue='false'
							blockSize='11'></u-slider>
						<view class="scoreCardTotalScore">{{ chooseExamObj.scoreCardTotalScore }}</view>
					</view>
					<view class="score-handle-inner">
						<view class="minScore"></view>
						<view class='scoreValue'>
							<view class="scoreMove"
								:style="'left:' + ((chooseExamObj.result / chooseExamObj.scoreCardTotalScore) * 100) + '%'">{{
									chooseExamObj.result }}</view>
						</view>
						<view class="scoreCardTotalScore"></view>
					</view>
				</view>
			</view>
		</u-modal>
		<!-- 打分 大分项end -->
		<!-- 打分 小分项start -->
		<u-modal :show="showScoreBig" @confirm="scoreBigHandle"  confirmColor='#00796B' :showCancelButton='false' width='460px'>
			<view style="width: 100%;display: flex;flex-direction: column;align-items: center;justify-content: center;">
				<view style="font-size: 20rpx;font-weight: 600;padding-bottom: 10rpx;">题干：</view>
				<view style="text-align: left;max-height: 100rpx;overflow: auto;width: 100%">{{ chooseExamObjBig.item }}</view>
				<view class="score-handle-box">
					<view class="score-handle-inner">
						<view class="minScore">0</view>
						<u-slider v-model="chooseExamObjBig.itemScoreResult" :step="Number(examScoreMin)" min="0"
							:max="chooseExamObjBig.itemScore" block-width="40" block-color="#00796B"
							activeColor="#00796B" inactiveColor=" #D9D9D9;" :showValue='false'
							blockSize='11'></u-slider>
						<view class="scoreCardTotalScore">{{ chooseExamObjBig.itemScore }}</view>
					</view>
					<view class="score-handle-inner">
						<view class="minScore"></view>
						<view class='scoreValue'>
							<view class="scoreMove"
								:style="'left:' + ((chooseExamObjBig.itemScoreResult / chooseExamObjBig.itemScore) * 100) + '%'">{{
									chooseExamObjBig.itemScoreResult }}</view>
						</view>
						<view class="scoreCardTotalScore"></view>
					</view>
				</view>
			</view>
		</u-modal>
		<!-- 打分 小分项end -->

		<quick-message ref="message"></quick-message>
		<!-- 提交 模态框 -->
		<u-modal :show="showSubmit" @confirm="confirmSubmit" @cancel='cancleSubmit' :disabled="!confirmSubmitLoading" confirmColor='#00796B' :showCancelButton='false' :showConfirmButton="false" :width="ifSign == '1' ? '600rpx': '300rpx'">
			<view class="submit-box">
				<view class="title">
					<text class="icon iconfont icon-querentijiao" style="font-size: 28px;padding-right: 14px;color: #00796B;font-weight: 600;"></text>
					请确认是否提交？
				</view>
				<view v-if="ifSign == '1'" class="sign-box">
					<!-- 启用签名 -->
					<view style="font-size: 20px;">签名：</view>
					<view style="width: 100% ;height: 440rpx; background: #f5f5f5;border-radius: 10rpx;display:flex;flex-direction:column;" v-if="showServeSign">
						<view style="height: 40px;width: 100%;display: flex;justify-content: flex-end;">
							<view>
								<u-button text="重新签名" :plain='true' @click="showServeSign = false"></u-button>
							</view>
						</view>
						<view class="servieImg" style="flex: 1;background: pink">
							 <image style="width: 100%; height: 100%; background-color: #eeeeee;" mode="aspectFit" :src="teacherSign"></image>
						</view>
					</view>
					<view style="width: 100% ;height: 440rpx; background: #f5f5f5;border-radius: 10rpx;" v-else>
						<view style="height: 40px;width: 100%;display: flex;justify-content: flex-end;">
							<view>
								<u-button text="清空" :plain='true' @click="onClick('clear')"></u-button>
							</view>
						</view>
						<l-signature disableScroll  ref="signatureRef" :penColor="penColor" :penSize="penSize" :openSmooth="openSmooth" ></l-signature>
					</view>
				</view>
				<view class="bot-btn3">
					<u-button text="取消" @click="cancleSubmit" size='large' style="width: 50%;margin-right: 20rpx;"></u-button>
					<u-button type="primary" :loading="confirmSubmitLoading" text="提交" @click="confirmSubmit" size='large' style="width: 50%;margin-left: 20rpx"></u-button>
				</view>
			</view>
		</u-modal>
		<u-modal :show="updateFlag" @confirm="confirmUpdate"  @cancel="confirmCancel" ref="uModal" confirmColor='#00796B' :showCancelButton='true' :asyncClose="true" width='360px'>
			<view style="font-size: 20px;padding: 20px 0;display: flex;align-items: center;flex-direction: column;">
				<text class="icon iconfont icon-tixing" style="font-size: 24px;padding-right: 4px;color:#FF001F"></text>
				请确认是否申请修改成绩？
			</view>
		</u-modal>
		<u-modal :show="permissionTextShow" title="驳回原因" width="300px" @confirm='permissionTextShow = false'>
			<view class="slot-content">
				<view>{{ permissionText }}</view>
			</view>
		</u-modal>

		<!-- 判断 两个老师打分查验成绩查是否大于 20% start -->
		<u-modal :show="showCheckExam" @confirm="dontCareHandle" @cancel='showCheckExam = false' confirmColor='#00796B' :showCancelButton='true' width='360px' confirmText="仍要提交" cancelText="修改成绩">
			<view style="font-size: 18px;padding: 20px 0;display: flex;align-items: center;flex-direction: column;">
				<text class="icon iconfont icon-xinxi1" style="font-size: 34px;padding-right: 4px;color: #d60734;"></text>
				<view style="padding: 20px 0 0;text-align: center;">提醒：{{ checkResult }}</view>
			</view>
		</u-modal>
		<!-- 判断 两个老师打分查验成绩查是否大于 20% end-->
	</view>
</template>
<script>
import luBarTabNav from "@/components/lu-bar-tab-nav/lu-bar-tab-nav.vue"
import mRequestIndex from '@/api/index.js'
import hccmConfig from '@/common/hccm-config.js'
import hccmStore from '@/common/hccm-store.js'
import { computedTimeNum, computedTimeStr } from '@/common/hccm-util.js'
export default {
	components: {
		luBarTabNav
	},
	data () {
		return {
			// null （不可以改，这是初始值）
			// 0（待审核）
			//  1（审核通过）
			//  2（审核驳回）
			ifPermission: null,
			idBak: '',
			useTime: '',
			updateFlag: false,
			showServeSign: false, //是否启用服务端签名
			value: 2,
			barFixed: true,
			barHeight: "44",
			barTop: 0,
			iconShow: true,
			transitionShow: true,
			barId: "0",
			tabList: [{
				text: "题目",
				navTarget: "#item1",
				iconClass: "icon01",
				iconImage: "",
				selectedIconClass: "",
				selectedIconImage: ""
			}, {
				text: "题干",
				navTarget: "#item2",
				iconClass: "icon02",
				iconImage: "",
				selectedIconClass: "",
				selectedIconImage: ""
			}, {
				text: "重要知识点",
				navTarget: "#item3",
				iconClass: "icon03",
				iconImage: "",
				selectedIconClass: "",
				selectedIconImage: ""
			}, {
				text: "物资、物品清单",
				navTarget: "#item4",
				iconClass: "icon04",
				iconImage: "",
				selectedIconClass: "",
				selectedIconImage: ""
			}, {
				text: "考评打分",
				navTarget: "#item5",
				iconClass: "icon05",
				iconImage: "",
				selectedIconClass: "",
				selectedIconImage: ""
			}
			],
			allScore: '',
			isPointed: '',

			// start
			examinationId: '',
			scanStudentId: '',
			examInfo: {},
			currentStudentInfo: {},
			status: '',
			startTime: '',
			ifSign: '',
			examScoreSet: '',// 大小分 1：大分项       2：小分项
			scoreCardList: [],
			showScore: false, //打分标识
			chooseExamObj: {
			}, //要打分的项
			showScoreBig: false,
			chooseExamObjBig: {
			}, //要打分的项
			showSubmit: false, //提交数据框
			confirmSubmitLoading: false, //提交loading
			submitLoading: false,
      intervalId: null,

			// 签名
			teacherInfo: {},
			teacherSign: '',
			permissionText: '',
			permissionTextShow: false,
			penColor: 'black',
			penSize: 10,
			openSmooth: '',
			examScoreMin: 0,

			showCheckExam: false, //两个老师打分查验成绩查是否大于 20%
			checkResult: '',
		}
	},
	onPageScroll: function (e) {
		this.$refs.barTabNav._selectedTab(e.scrollTop)
	},
	onHide(){
	},
	onUnload() {
	},
	beforeDestroy() {
	},
	onLoad(options) {
    this.examinationId = options.examinationId
    this.scanStudentId = options.scanStudentId
    this.examScoreMin = options.examScoreMin
    this.getExaminationDetail(this.examinationId)
    this.getStudentInfo(this.scanStudentId)
		this.getInspectList(hccmStore.getUser().teacherId)
		
	},
	computed: {
		matchScore() {
			let scoreBak = 0
			this.scoreCardList.map(val => {
				val.children.map(p => {
					scoreBak += p.scoreCardTotalScore
				})
			})
			return scoreBak
		}
	},
	watch:{
		scoreCardList:{
      handler: function (newValue, oldValue) {
        // 当nestedData对象的属性变化时，这个函数会被调用
				this.getAllScore()
      },
      deep: true,
    }
	},
	methods: {
		// 不关心 成绩分差是否大约20%
		dontCareHandle(){
			this.showCheckExam = false
			this.showSubmit = true
		},
		toShow(){
			this.permissionTextShow = true
			console.log(2222, this.permissionText)
		},
		// 获取考试详情
		getDetails(){
			let params = {
				teacherId: hccmStore.getUser().teacherId,
				recordsStudentId: this.scanStudentId
			}
			mRequestIndex.getStudentExamDetail(params).then(res => {
				// 评分卡
				let scoreCardListBak = res.data.examDetails.sort((a,b) => {
					return a.ordersn - b.ordersn
				})
				let fatherIdsBak = scoreCardListBak.map(v => {
					return v.scoreCardItem
				})
				let fatherIds = [... new Set(fatherIdsBak)]
				let newArr = []
				fatherIds.map(item=>{
					newArr.push({
						item: item,
						itemScore: 0,
						itemScoreResult: 0,
						children: []
					})
				})
				if(this.examScoreSet == '1'){
					// 大分项
					scoreCardListBak.map(q => {
						newArr.map(p => {
							if(q.scoreCardItem === p.item){
								p.children.push(Object.assign(q,{result: q.scoreCardTotalScore}))
								p.itemScore = p.itemScore + q.scoreCardTotalScore
								p.itemScoreResult = p.children[0].bigResult
							}
						})
					})
					this.scoreCardList = JSON.parse(JSON.stringify(newArr))
				}else {
					// 小分项
					scoreCardListBak.map(q => {
						newArr.map(p => {
							if(q.scoreCardItem === p.item){
								p.children.push(Object.assign(q,{result: q.result}))
								p.itemScore = p.itemScore + q.scoreCardTotalScore
							}
						})
					})
					this.scoreCardList = JSON.parse(JSON.stringify(newArr))
				}
				this.ifPermission = res.data.studentExamination.ifPermission
				this.idBak = res.data.studentExamination.id
				this.useTime = res.data.studentExamination.examTime
				this.teacherSign = res.data.studentExamination.teacherSign
				this.permissionText = res.data.studentExamination.permissionText
				console.log('this.ss', this.ifPermission)
			})
		},
		// 获取得分
		getAllScore(){
			let scoreBak = 0
			if(this.examScoreSet == '1'){
				this.scoreCardList.map(val => {
					if (val.itemScoreResult !== null && val.itemScoreResult !== undefined) {
						scoreBak += val.itemScoreResult
					}
				})
				this.allScore = scoreBak
			}else{
				this.scoreCardList.map(val => {
					val.children.map(q => {
						if (q.result !== null && q.result !== undefined) {
							scoreBak += q.result
						}
					})
				})
				this.allScore = scoreBak.toFixed(2)
			}
		},
		// 大分项打分

		// 小分项打分
		chooseExam(item){
			this.chooseExamObj = JSON.parse(JSON.stringify(item))
			this.showScore = true
		},
		chooseExamBig(item,index){
			this.chooseExamObjBig = JSON.parse(JSON.stringify(item))
			this.chooseExamObjBig.index = index
			this.showScoreBig = true
		},
		scoreHandle(){
			this.scoreCardList.map(v => {
				v.children.map(p => {
					if(p.id === this.chooseExamObj.id){
						p.result = this.chooseExamObj.result
					}
				})
			})
			this.showScore = false
		},
		scoreBigHandle(){
			this.scoreCardList.map((v,ind) => {
				if(v.item === this.chooseExamObjBig.item && ind === this.chooseExamObjBig.index){
					v.itemScoreResult = this.chooseExamObjBig.itemScoreResult
				}
			})
			this.showScoreBig = false
		},
		// 签名 start
		onClick(type) {
			if(type == 'openSmooth') {
				this.openSmooth = !this.openSmooth
				return
			}
			if (type == 'save') {
				if(this.showServeSign){
					// 如果使用线上的签名 ，不需要进行校验，直接提交
					this.confirmSubmitLoading = true
					let params = {
						recordsId: this.currentStudentInfo.recordsId,
						recordsDateId: this.currentStudentInfo.recordsDateId,
						recordsStationId: this.currentStudentInfo.recordsStationId,
						recordsStudentId: this.scanStudentId,
						examinationId: this.examinationId,
						examinationName: this.examInfo.examInfoProps.examName,
						result: Number(this.allScore),
						totalScore: this.matchScore,
						examTime: this.useTime,
						teacherId: hccmStore.getUser().teacherId,
						teacherName: hccmStore.getUser().nickname,
						teacherSign: this.teacherSign,
						isEdit: 1,
					}
					this.examInfo.scoreCardList.map(val=>{
						val.scoreCardId = val.id
						delete val.id
					})
					if(this.examScoreSet == '1'){
						// 分赋值 大分项
						this.examInfo.scoreCardList.map(p => {
							this.scoreCardList.map(q => {
								if(p.scoreCardItem === q.item){
									p.bigResult = q.itemScoreResult
									p.allBigResult = q.itemScore
								}
							})
						})
					}else{
						// 分赋值 小分项
						let scoreCardListBak = []
						this.scoreCardList.map( v => {
							scoreCardListBak = scoreCardListBak.concat(v.children)
						})
						this.examInfo.scoreCardList.map(p => {
							scoreCardListBak.map(q => {
								if(p.scoreCardId === q.scoreCardId){
									p.result = q.result
								}
							})
						})
					}
					params.scoreCardList = JSON.parse(JSON.stringify(this.examInfo.scoreCardList))
					mRequestIndex.submitExamination(params).then(res=>{
						if(res.code == 0){
							this.$refs.message.show({
								type:'success', //String 默认default
								msg:'考试成绩提交成功', //String 显示内容 *
								direction:'top', //String 默认顶部显示
								icon:true, //Boolean|String 显示icon(false/true/string 默认显示icon)
								mask:true, //Boolean 遮罩（默认false没有遮罩）
								time:1000, //Number|Boolean 默认3000/false为不自动关闭
								customStyle:{ //自定义样式
									// color:'#FFFFFF', //字体图标色
									// backgroundColor:'rgba(0,0,0,.5)', //背景色
									fontSize: 12,
								}, 
								iconSize: 16, //Number 自定义icon大小(单位px 默认16 设置后会覆盖自定义样式里的设置优先级最高)
								iconColor: '', //String icon颜色(默认主题颜色 设置后会覆盖自定义样式里的设置优先级最高)
							})
							this.showSubmit = false
							this.confirmSubmitLoading = false
							uni.removeStorageSync('exam_time')
							setTimeout(() => {
								uni.reLaunch({
									url: '/pages/home/index'
								})
							}, 1000);
						}
					})
				}else{
					this.$refs.signatureRef.canvasToTempFilePath({
						success: (res) => {
							// 是否为空画板 无签名
							if(res.isEmpty){
								this.$refs.message.show({
									type:'warning', //String 默认default
									msg:'请先填写签名', //String 显示内容 *
									direction:'top', //String 默认顶部显示
									icon:true, //Boolean|String 显示icon(false/true/string 默认显示icon)
									mask:true, //Boolean 遮罩（默认false没有遮罩）
									time:1000, //Number|Boolean 默认3000/false为不自动关闭
									customStyle:{ //自定义样式
										// color:'#FFFFFF', //字体图标色
										// backgroundColor:'rgba(0,0,0,.5)', //背景色
										fontSize: 12,
									}, 
									iconSize: 16, //Number 自定义icon大小(单位px 默认16 设置后会覆盖自定义样式里的设置优先级最高)
									iconColor: '', //String icon颜色(默认主题颜色 设置后会覆盖自定义样式里的设置优先级最高)
								})
							} else {
								// 生成图片的临时路径
								// H5 生成的是base64
								uni.uploadFile({
									url: `${hccmConfig.HCCM_HOST_URL}/osce-api/tool/upload/uploadMultipartFile`,
									filePath: res.tempFilePath,
									name: 'file',
									header: {
										token: hccmStore.getPhoneToken(),
									},
									formData: {
										// 其他请求参数
									},
									success: (res) => {
										if (res.data) {
											let JSONParse = JSON.parse(res.data)
											this.urlBak = JSONParse.url
											// console.log(JSONParse)
											// 提交签名
											let paramsTeacher = Object.assign(this.teacherInfo,{teacherSign: JSONParse.url})
											mRequestIndex.recordsStationTeacherSaveOrUpdate(paramsTeacher).then(resPonse => {
												console.log('resPonse',resPonse)
											})
											// this.saveOrUpdate(res.url)
											this.confirmSubmitLoading = true
											let params = {
												recordsId: this.currentStudentInfo.recordsId,
												recordsDateId: this.currentStudentInfo.recordsDateId,
												recordsStationId: this.currentStudentInfo.recordsStationId,
												recordsStudentId: this.scanStudentId,
												examinationId: this.examinationId,
												examinationName: this.examInfo.examInfoProps.examName,
												result: Number(this.allScore),
												totalScore: this.matchScore,
												examTime: this.useTime,
												teacherId: hccmStore.getUser().teacherId,
												teacherName: hccmStore.getUser().nickname,
												teacherSign: JSONParse.url,
												isEdit: 1,
											}
											this.examInfo.scoreCardList.map(val=>{
												val.scoreCardId = val.id
												delete val.id
											})
											if(this.examScoreSet == '1'){
												// 分赋值 大分项
												this.examInfo.scoreCardList.map(p => {
													this.scoreCardList.map(q => {
														if(p.scoreCardItem === q.item){
															p.bigResult = q.itemScoreResult
															p.allBigResult = q.itemScore
														}
													})
												})
											}else{
												// 分赋值 小分项
												let scoreCardListBak = []
												this.scoreCardList.map( v => {
													scoreCardListBak = scoreCardListBak.concat(v.children)
												})
												console.log('scoreCardListBak',scoreCardListBak)
												console.log('this.examInfo.scoreCardList',this.examInfo.scoreCardList)
												this.examInfo.scoreCardList.map(p => {
													scoreCardListBak.map(q => {
														if(p.scoreCardId === q.scoreCardId){
															p.result = q.result
														}
													})
												})
											}
											params.scoreCardList = JSON.parse(JSON.stringify(this.examInfo.scoreCardList))
											mRequestIndex.submitExamination(params).then(res=>{
												if(res.code == 0){
													this.$refs.message.show({
														type:'success', //String 默认default
														msg:'考试成绩提交成功', //String 显示内容 *
														direction:'top', //String 默认顶部显示
														icon:true, //Boolean|String 显示icon(false/true/string 默认显示icon)
														mask:true, //Boolean 遮罩（默认false没有遮罩）
														time:1000, //Number|Boolean 默认3000/false为不自动关闭
														customStyle:{ //自定义样式
															// color:'#FFFFFF', //字体图标色
															// backgroundColor:'rgba(0,0,0,.5)', //背景色
															fontSize: 12,
														}, 
														iconSize: 16, //Number 自定义icon大小(单位px 默认16 设置后会覆盖自定义样式里的设置优先级最高)
														iconColor: '', //String icon颜色(默认主题颜色 设置后会覆盖自定义样式里的设置优先级最高)
													})
													this.showSubmit = false
													this.confirmSubmitLoading = false
													uni.removeStorageSync('exam_time')
													setTimeout(() => {
														uni.reLaunch({
															url: '/pages/home/index'
														})
													}, 1000);
												}
											})
										}
									}
								});
							}
						}
					})
				}
				return
			}
			if (this.$refs.signatureRef){
				this.$refs.signatureRef[type]()
			}
		},
		// 签名 end
		// 确认提交
		confirmSubmit(){
			if(this.ifSign == '1'){
				// 签名
				this.onClick('save')
			} else {
				const now = new Date().getTime()
      	const startTime = new Date(this.startTime).getTime()
				this.confirmSubmitLoading = true
				let params = {
					recordsId: this.currentStudentInfo.recordsId,
					recordsDateId: this.currentStudentInfo.recordsDateId,
					recordsStationId: this.currentStudentInfo.recordsStationId,
					recordsStudentId: this.scanStudentId,
					examinationId: this.examinationId,
					examinationName: this.examInfo.examInfoProps.examName,
					result: Number(this.allScore),
					totalScore: this.matchScore,
					examTime: this.useTime,
					teacherId: hccmStore.getUser().teacherId,
					teacherName: hccmStore.getUser().nickname,
					isEdit: 1,
				}
				this.examInfo.scoreCardList.map(val=>{
					val.scoreCardId = val.id
					delete val.id
				})
				// 分赋值
				if(this.examScoreSet == '1'){
					// 分赋值 大分项
					this.examInfo.scoreCardList.map(p => {
						this.scoreCardList.map(q => {
							if(p.scoreCardItem === q.item){
								p.bigResult = q.itemScoreResult
								p.allBigResult = q.itemScore
							}
						})
					})
				}else{
					// 分赋值 小分项
					let scoreCardListBak = []
					this.scoreCardList.map( v => {
						scoreCardListBak = scoreCardListBak.concat(v.children)
					})
					this.examInfo.scoreCardList.map(p => {
						scoreCardListBak.map(q => {
							if(p.scoreCardId === q.scoreCardId){
								p.result = q.result
							}
						})
					})
				}
				params.scoreCardList = JSON.parse(JSON.stringify(this.examInfo.scoreCardList))
				mRequestIndex.submitExamination(params).then(res=>{
					if(res.code == 0){
						this.$refs.message.show({
							type:'success', //String 默认default
							msg:'考试成绩提交成功', //String 显示内容 *
							direction:'top', //String 默认顶部显示
							icon:true, //Boolean|String 显示icon(false/true/string 默认显示icon)
							mask:true, //Boolean 遮罩（默认false没有遮罩）
							time:1000, //Number|Boolean 默认3000/false为不自动关闭
							customStyle:{ //自定义样式
								// color:'#FFFFFF', //字体图标色
								// backgroundColor:'rgba(0,0,0,.5)', //背景色
								fontSize: 12,
							}, 
							iconSize: 16, //Number 自定义icon大小(单位px 默认16 设置后会覆盖自定义样式里的设置优先级最高)
							iconColor: '', //String icon颜色(默认主题颜色 设置后会覆盖自定义样式里的设置优先级最高)
						})
						this.showSubmit = false
						this.confirmSubmitLoading = false
						uni.removeStorageSync('exam_time')
						setTimeout(() => {
							uni.reLaunch({
								url: '/pages/home/index'
							})
						}, 1000);
					}
				})
			}
		},
		cancleSubmit(){
			this.showSubmit = false
		},
		submit(){
			// 先校验 两个老师打分查验成绩查是否大于 20%
			let params = {
				recordsStudentId: this.scanStudentId,
				result: Number(this.allScore)
			}
			mRequestIndex.checkExam(params).then(res=>{
				// checkExam:1不提示   0提示
				if(res.checkExam === 1){
					this.showSubmit = true
				}else{
					this.showCheckExam = true
					this.checkResult = res.checkResult
				}
			})
		},
		confirmUpdate(){
			mRequestIndex.submitPermission({id: this.idBak}).then(res => {
				console.log(res)
				this.$refs.message.show({
					type:'success', //String 默认default
					msg:'申请已提交', //String 显示内容 *
					direction:'top', //String 默认顶部显示
					icon:true, //Boolean|String 显示icon(false/true/string 默认显示icon)
					mask:true, //Boolean 遮罩（默认false没有遮罩）
					time:1000, //Number|Boolean 默认3000/false为不自动关闭
					customStyle:{ //自定义样式
						// color:'#FFFFFF', //字体图标色
						// backgroundColor:'rgba(0,0,0,.5)', //背景色
						fontSize: 12,
					}, 
					iconSize: 16, //Number 自定义icon大小(单位px 默认16 设置后会覆盖自定义样式里的设置优先级最高)
					iconColor: '', //String icon颜色(默认主题颜色 设置后会覆盖自定义样式里的设置优先级最高)
				})
				setTimeout(() => {
					this.updateFlag = false
					uni.reLaunch({
						url: '/pages/home/index'
					})
				}, 1000);
			})
		},
		confirmCancel(){
			this.updateFlag = false
		},
		// 申请修改成绩
		updateExam(){
			this.updateFlag = true
		},
		// 获取考试内容
    getExaminationDetail(examinationId){
      mRequestIndex.examinationDetail({examinationId}).then(res=>{
        this.examInfo = res.data
        this.examInfo.examInfoProps = {
          examName: this.examInfo.examName,
          examText: this.examInfo.examText
        }
				this.examInfo.selfInspectionCardList = this.examInfo.selfInspectionCardList.sort((a,b) => {
					return a.ordersn - b.ordersn
				})
      })
    },

		// 考生信息
    getStudentInfo(id){
      mRequestIndex.recordsStationStudentList({id}).then(res=>{
        this.currentStudentInfo = res.data.records[0]
        this.status = this.currentStudentInfo.status
      })
    },

		// 考试的时长 是否签名 大小分设置
		getInspectList(teacherId){
      mRequestIndex.getRealTimeData({
        recordsTeacherId: teacherId,
      }).then(res=>{
				console.log('考试的时长 是否签名 大小分设置',res.data)
        this.ifSign = res.data.ifSign
        this.examScoreSet = res.data.examScoreSet
				// 获取考试详情
				this.getDetails()
      })
    },
	}

}
</script>

<style lang='scss'>
.page-content {
	position: relative;
	width: 100%;
	display: flex;
	flex-flow: row wrap;
	justify-content: center;
	align-items: center;
	background-color: #f5f5f5;
	font-size: 14rpx;
	padding-bottom: 120rpx;
}

.banner {
	position: relative;
	width: 100%;
	height: 200rpx;
}

.tabbody {
	position: relative;
	width: 100%;
	padding: 10rpx 10rpx;
	box-sizing: border-box;
	.title{
		height: 40rpx;
		text-indent: 14rpx;
		font-size: 18rpx;
		color: #00796B;
		position: relative;
	}
	.title:before{
		content: '';
		height: 16rpx;
		width: 3rpx;
		border-radius: 10rpx;
		background: #00796B;
		position: absolute;
		left: 0;
		top: 4rpx;
	}
	.innerBox{
		padding: 10rpx;
		border: 1rpx solid #00796B50;
		background: #fff;
		border-radius: 10rpx;
		font-size: 18rpx;
	}
}
// 物资物品清单
.innerBox1{
	padding: 0 !important;
	overflow: hidden;
	.wuzi-box{
		background: rgba(72,83,104,0.5);
		color: #000;
		display: flex;
		min-height: 50rpx;
		font-size: 16rpx;
		align-items: center;
		.left{
			height: 100%;
			min-height: 50rpx;
			width: 80rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
		.mid{
			flex: 1;
			height: 100%;
			min-height: 50rpx;
			padding:0 10rpx;
			border-left: 1rpx solid #00796B50;
			border-right: 1rpx solid #00796B50;
			display: flex;
			align-items: center;
		}
		.right{
			height: 100%;
			width: 80rpx;
			min-height: 50rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
		.left1{
			width: 140rpx;
		}
		.mid1{
			justify-content: center;
		}
		.right1{
			width: 80rpx;
			border-right: 1rpx solid #00796B50;
		}
		.right2{
			width: 100rpx;
		}
	}
	.wuzi-box2{
		background: rgba(255,255,255,1);
		border-bottom: 1rpx solid #00796B50;
		color: #333;
		// min-height: 50rpx;
	}
	.wuzi-box2:last-of-type{
		border-bottom: none;
	}

	.innerTitle{
		
	}
}

// score 底部按钮
.fixed-score-box {
	position: fixed;
	z-index: 1000;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 120rpx;
	padding: 6rpx 10rpx 10rpx;
	border: 1px solid #F1F3F4;
	background: #fff;
	justify-content: space-between;
	align-items: flex-start;
	flex-direction: column;
  box-sizing: border-box;

	.top-box {
		height: 45rpx;
		display: flex;
		justify-content: space-between;
		width: 100%;
		padding: 0 40rpx;
		box-sizing: border-box;
    .btn-box{
      display: flex;
			align-items: center;
    }
		.score-box-outer {
			color: #333333;
			font-size: 18rpx;
			font-weight: 600;
			justify-content: space-between;
			display: flex;
			flex-direction: column;
			.score-num {
				font-size: 14rpx;
				color: #333;
				font-weight: 600;
				display: flex;
				justify-content: flex-end;
			}
		}
	}

	.bottom-box {
		padding-top: 15rpx;
		width: 100%;
	}
	
}
.score-handle-box {
	width: 100%;
	height: 74px;
	background: #F8FAFA;
	padding: 10px;
	padding-top: 30px;
	margin-top: 10px;
	position: relative !important;

	.score-handle-inner {
		display: flex;
		justify-content: center;
		align-items: center;
		min-height: 10px;

		.minScore,
		.scoreCardTotalScore {
			font-size: 13px;
			color: #777;
			width: 10px;
		}

		.u-slider {
			flex: 1;
			margin: 0 3px;
		}
		.scoreValue {
			flex: 1;
			margin: 0 3px;
			bottom: 0px;
			font-size: 15px;
			color: #333;
			font-weight: 600;
			position: relative;
			min-height: 10px;
			margin: 0 20px;

			.scoreMove {
				position: absolute;
				top: -60px;
				color: rgb(0, 121, 107);
			}
		}
	}
}
.submit-box{
	width: 100%;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	.title{
		font-size: 22px;
		padding-bottom: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.sign-box{
		// height: 500rpx;
		width: 100%;
		// background: #f5f5f5;
		border: 1px solid #00796B;
		padding: 10rpx;
		border-radius: 10rpx;
		.sign-btn{
			padding-top: 10rpx;
			width: 100%;
			// background: rgb(205, 204, 204);
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
}
.bot-btn3{
	display: flex;
	padding-top: 10rpx;
	width: 100%;
}
.info-wrap {
		padding: 10px 20px 10px;
		font-size: 13px;
		width: 260px;
		height: 30px;
		box-sizing: content-box;
		color: #333333;
		font-size: 15px;
		font-weight: 600;
		justify-content: flex-end;
    display: flex;
		align-items: center;
		.longTime {
			height: 30px;
			line-height: 30px;
      padding: 0 10px;
			margin-left: 10rpx;
			border-radius: 4px;
			background: #E5FEE7;
			border-radius: 3px;
			color: #333;
		}
	}
	:deep(uni-slider .uni-slider-handle-wrapper){
		height: 16rpx !important;
	}
	:deep(uni-slider .uni-slider-thumb){
		width: 18px !important;
    height: 18px !important;
    margin-left: -9px !important;
    margin-top: -9px !important;
	}
</style>